package com.modules.model;

import com.modules.utils.DateConvertUtils;
import org.hibernate.validator.constraints.Length;

import javax.persistence.*;
import java.util.Date;

import static com.modules.model.SimpleModel.DATE_FORMAT;

/**
 * Created by lewis on 2017/7/15.
 */
@MappedSuperclass
public class FlowModelExt extends SimpleModelExt {

    private static final long	serialVersionUID	= 413825552179236104L;

    /**
     * 工作流实例id
     */
    @Length(max = 64)
    @Column(name = "WF_ID_", unique = false, nullable = true, insertable = true, updatable = true, length = 64)
    private String				wfId;

    /**
     * 工作流状态，如：待审核、已审核、已退回，一般为两位数字编码
     */
    @Length(max = 128)
    @Column(name = "WF_STATUS_", unique = false, nullable = true, insertable = true, updatable = true, length = 128)
    private String				wfStatus;

    /**
     * 提交人staffCode
     */
    @Length(max = 64)
    @Column(name = "SUBMITTER_", nullable = true, insertable = true, updatable = true, length = 64)
    private String				submitter;

    /**
     * 提交人staffName
     */
    @Length(max = 64)
    @Column(name = "SUBMITTER_NAME_", nullable = true, insertable = true, updatable = true, length = 64)
    private String				submitterName;

    /**
     * 提交日期
     */
    @Column(name = "SUBMIT_DATE_", nullable = true, insertable = true, updatable = true, length = 10)
    @Temporal(TemporalType.DATE)
    private Date submitDate;

    /**
     * 复核人staffCode
     */
    @Length(max = 64)
    @Column(name = "REVIEWER_", nullable = true, insertable = true, updatable = true, length = 64)
    private String				reviewer;

    /**
     * 复核人staffName
     */
    @Length(max = 64)
    @Column(name = "REVIEWER_NAME_", nullable = true, insertable = true, updatable = true, length = 64)
    private String				reviewerName;

    /**
     * 复核日期
     */
    @Column(name = "REVIEW_DATE_", nullable = true, insertable = true, updatable = true, length = 10)
    @Temporal(TemporalType.DATE)
    private Date				reviewDate;

    /**
     * 审批人staffCode
     */
    @Length(max = 64)
    @Column(name = "APPROVER_", nullable = true, insertable = true, updatable = true, length = 64)
    private String				approver;

    /**
     * 审批人staffName
     */
    @Length(max = 64)
    @Column(name = "APPROVER_NAME_", nullable = true, insertable = true, updatable = true, length = 64)
    private String				approverName;

    /**
     * 审批日期
     */
    @Column(name = "APPROVE_DATE_", nullable = true, insertable = true, updatable = true, length = 10)
    @Temporal(TemporalType.DATE)
    private Date				approveDate;

    /**
     * 审核人staffCode
     */
    @Length(max = 64)
    @Column(name = "AUDITOR_", nullable = true, insertable = true, updatable = true, length = 64)
    private String				auditor;

    /**
     * 审核人staffName
     */
    @Length(max = 64)
    @Column(name = "AUDITOR_NAME_", nullable = true, insertable = true, updatable = true, length = 64)
    private String				auditorName;

    /**
     * 审核日期
     */
    @Column(name = "AUDIT_DATE_", nullable = true, insertable = true, updatable = true, length = 10)
    @Temporal(TemporalType.DATE)
    private Date				auditDate;

    public String getWfId() {
        return wfId;
    }

    public void setWfId(String wfId) {
        this.wfId = wfId;
    }

    public String getWfStatus() {
        return wfStatus;
    }

    public void setWfStatus(String wfStatus) {
        this.wfStatus = wfStatus;
    }

    public String getSubmitter() {
        return submitter;
    }

    public void setSubmitter(String submitter) {
        this.submitter = submitter;
    }

    public String getSubmitterName() {
        return submitterName;
    }

    public void setSubmitterName(String submitterName) {
        this.submitterName = submitterName;
    }

    public Date getSubmitDate() {
        return submitDate;
    }

    public void setSubmitDate(Date submitDate) {
        this.submitDate = submitDate;
    }

    public String getReviewer() {
        return reviewer;
    }

    public void setReviewer(String reviewer) {
        this.reviewer = reviewer;
    }

    public String getReviewerName() {
        return reviewerName;
    }

    public void setReviewerName(String reviewerName) {
        this.reviewerName = reviewerName;
    }

    public Date getReviewDate() {
        return reviewDate;
    }

    public void setReviewDate(Date reviewDate) {
        this.reviewDate = reviewDate;
    }

    public String getApprover() {
        return approver;
    }

    public void setApprover(String approver) {
        this.approver = approver;
    }

    public String getApproverName() {
        return approverName;
    }

    public void setApproverName(String approverName) {
        this.approverName = approverName;
    }

    public Date getApproveDate() {
        return approveDate;
    }

    public void setApproveDate(Date approveDate) {
        this.approveDate = approveDate;
    }

    public String getAuditor() {
        return auditor;
    }

    public void setAuditor(String auditor) {
        this.auditor = auditor;
    }

    public String getAuditorName() {
        return auditorName;
    }

    public void setAuditorName(String auditorName) {
        this.auditorName = auditorName;
    }

    public Date getAuditDate() {
        return auditDate;
    }

    public void setAuditDate(Date auditDate) {
        this.auditDate = auditDate;
    }

    @Transient
    public String getSubmitDateString() {
        return DateConvertUtils.format(getSubmitDate(), DATE_FORMAT);
    }

    public void setSubmitDateString(String value) {
        setSubmitDate(DateConvertUtils.parse(value, DATE_FORMAT, Date.class));
    }

    @Transient
    public String getAuditDateString() {
        return DateConvertUtils.format(getAuditDate(), DATE_FORMAT);
    }

    public void setAuditDateString(String value) {
        setAuditDate(DateConvertUtils.parse(value, DATE_FORMAT, Date.class));
    }



    @Transient
    public String getReviewDateString() {
        return DateConvertUtils.format(getReviewDate(), DATE_FORMAT);
    }

    public void setReviewDateString(String value) {
        setReviewDate(DateConvertUtils.parse(value, DATE_FORMAT, Date.class));
    }


    @Transient
    public String getApproveDateString() {
        return DateConvertUtils.format(getApproveDate(), DATE_FORMAT);
    }

    public void setApproveDateString(String value) {
        setApproveDate(DateConvertUtils.parse(value, DATE_FORMAT, Date.class));
    }

}